package it11.Capood.GUI;

import it11.Capood.R;
import it11.Capood.DataLogic.TextMessage;
import android.os.Bundle;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;

public class ReceivingTextActivity extends Activity {

	public final static String EXTRA_MESSAGE = "message";
	
	private EditText edit_text;
	private TextMessage msg;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_receiving_text);
		
		edit_text = (EditText) findViewById(R.id.editText_text);
	}
	
	@Override
	public void onStart(){
		super.onStart();
		
		msg = (TextMessage) getIntent().getSerializableExtra(EXTRA_MESSAGE);
		if (msg != null){
			edit_text.setText(msg.getMessage());
		}
	}
	
	
	public void click_history(View view){
		Intent intent = new Intent(this,HistoryActivity.class);
		
		startActivity(intent);
	}
	
	public void click_copy_to_clipboard(View view){
		ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
		
		cm.setPrimaryClip(ClipData.newPlainText("Capood", edit_text.getText().toString()));
	}

}
